package com.fzq.web.controller;

import com.fzq.server.mapper.MinioService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.meta.TypeQualifier;
import java.io.File;

/**
 * @author fzq
 * @date 2025/4/22 - 11:53
 **/
@Slf4j
@RestController
@RequestMapping("/minio")
public class MinionController {

    @Autowired
    MinioService minioService;

    @PostMapping("/push")
    public void putminio(@RequestParam(value = "bucketName", required = false) String bucketName,
                         @RequestParam("file") MultipartFile file) {

        // 业务逻辑（例如上传到MinIO）
        if (file.isEmpty()) {
            throw new IllegalArgumentException("文件不能为空");
        }
        minioService.putminio(bucketName,file);
    }

    @PostMapping("/push/test")
    public void putminiotest(@RequestParam(value = "bucketName", required = false) String bucketName) {
        minioService.putminiotest(bucketName);
    }
}
